package com.neuedu.javase.api;

/**
 * @auth 金山老师
 * title:   书籍代码
 * creatime: 2022-09-28 13:34
 * 描述 : 包装类
 */
public class MyWrapper {

    public static void main(String[] args) {
        /**
         *  char                    Character
         *  boolean                 Boolean
         *  byte short int long     Byte Short Integer Long
         *  float double            Float  Double
         */
        System.out.println("Byte.MAX_VALUE = " + Byte.MAX_VALUE);
        System.out.println("Byte.MIN_VALUE = " + Byte.MIN_VALUE);

        System.out.println("Character.isDigit('a') = " + Character.isDigit('a'));  //false
        System.out.println("Character.isDigit('1') = " + Character.isDigit('1'));  //true
        System.out.println("Character.isLetter('1') = " + Character.isLetter('1'));  //false
        System.out.println("Character.isLetter('t') = " + Character.isLetter('t'));  //true


        /**
         * 类型转换
         */
        
        int numa = 100;
        Integer intObj = new Integer(50);


        //基础类型转包装类型  构造构造函数
        Integer intObj1 = new Integer(numa);

        //包装类型转换成 基础类型   xxxxxValue
        int numb = intObj1.intValue();

        System.out.println("intObj1 = " + intObj1); //100
        System.out.println("numb = " + numb);   // 100


        //复习典型，将基础类型转换成包装类
        Double d1 = new Double(3.14);
        //包装类型转换成 基础类型   xxxxxValue
        double d2 = d1.doubleValue();
        System.out.println("d1 = " + d1);
        System.out.println("d2 = " + d2);



        //字符串 转基础类型
        String  intString = "100";
        int intNum = Integer.parseInt(intString);


        //基础类型转字符串
        System.out.println("intNum = " + intNum);
        String strInt = String.valueOf(intNum); //ALT +ENTER 提示       表达式.var  定义变量


        //字符串转-->  包装类型    Double.valueOf
         String  doubleString = "3.14";
        Double aDouble = Double.valueOf(doubleString);


        //包装类型转 字符串
        String strDouble = aDouble.toString();
        System.out.println("strDouble.length() = " + strDouble.length());


        /**
         *  jdk 1.5 支持 自动装箱 拆箱
         */

        //自动的装箱
        Integer intObj3 =  50;
        Double doubleObj3 =  50.34;

        //自动的拆箱
//        Integer iiObject =  new Integer(10);
//        int numc = iiObject;


        //new Integer(10) 匿名对象
        int numc = new Integer(10);






    }
}
